<?php

namespace ManiaLivePlugins\MLEPP\TmxInfo\Gui\Windows;

use ManiaLive\PluginHandler\PluginHandler;

use ManiaLib\Gui;
use ManiaLive\Gui\Windowing\Controls;
use ManiaLive\Gui\Windowing\Controls\Frame;
use ManiaLive\Gui\Windowing\Controls\Panel;
use ManiaLib\Gui\Elements\Label;
use ManiaLib\Gui\Elements\Quad;
use ManiaLib\Gui\Elements\Button;

class SimpleWindow extends \ManiaLive\Gui\Windowing\ManagedWindow
{
    protected $panel;
    protected $label;
    protected $Image;
    protected $TmxID;
    protected $TrackName;
    protected $Username;
    protected $Uploaded;
    protected $Environment; 
    protected $Mood;
    protected $Style;
    protected $Routes;
    protected $Length;
    protected $Difficulty;
    protected $LBscore;
    protected $Gameversion;
    protected $data; 
	protected $tmx;   
       
    function initializeComponents()
    {        
        $this->panel = new Panel();
        $this->panel->setPosition(2, 6);
        $this->addComponent($this->panel);
                    
        $this->frame = new Frame();
        $this->frame->setPosition(80, 60);
        $this->panel->addComponent($this->frame);

		$this->btnTrack = new Button();
        $this->frame->addComponent($this->btnTrack);
        $this->Image = new Quad();
        $this->frame->addComponent($this->Image);
        $this->TmxID = new Label();
        $this->frame->addComponent($this->TmxID);
        $this->TrackName= new Label();
        $this->panel->addComponent($this->TrackName);
        $this->Username= new Label();
        $this->panel->addComponent($this->Username);
        $this->Uploaded= new Label();
        $this->panel->addComponent($this->Uploaded);
        $this->Environment= new Label();
        $this->panel->addComponent($this->Environment);
        $this->Mood= new Label();
        $this->panel->addComponent($this->Mood);
        $this->Style= new Label();
        $this->panel->addComponent($this->Style);
        $this->Routes= new Label();
        $this->panel->addComponent($this->Routes);
        $this->Length= new Label();
        $this->panel->addComponent($this->Length);
        $this->Difficulty = new Label();
        $this->panel->addComponent($this->Difficulty);
        $this->Gameversion = new Label();
        $this->panel->addComponent($this->Gameversion);
        $this->URL = new Label();
        $this->panel->addComponent($this->URL);
        $this->Image->setImage('http://'.$this->tmx.'.tm-exchange.com/get.aspx?action=trackscreen&id='. $this->data[0].'&.jpg', true);        

    }
   
	function onDraw() 
	{

	$this->panel->clearComponents();
	$this->setTitle('TMX info for ' .$this->data[1]);
	$this->TmxID->setText('$oTMX ID:                       '.$this->data[0].'');
	$this->TrackName->setText('$oTrackname:                    '.$this->data[1].'');
	$this->Username->setText('$o'.$this->data[1].'  $oMade By:  $o'.$this->data[3].'');
	$this->Uploaded->setText('$oUploaded:          '.$this->data[4].'');
	$this->Environment->setText('$oEnvironment:                  '.$this->data[8].'');
	$this->Mood->setText('$oMood:                              '.$this->data[9].'');
	$this->Style->setText('$oStyle:                               '.$this->data[10].'');
	$this->Routes->setText('$oRoutes:                           '.$this->data[11].'');
	$this->Length->setText('$oLength:                             '.$this->data[12].'');
	$this->Difficulty->setText('$oDifficulty:                      '.$this->data[13].'');
	$this->Gameversion->setText('$oGameVersion:              '.$this->data[15].'');
	$this->btnTrack->setText('Visit '.$this->data[1].' on TMX');
	$this->btnTrack->setUrl('http://'.$this->tmx.'.tm-exchange.com/main.aspx?action=trackshow&id='.$this->data[0]);
	$this->Image->setImage('http://'.$this->tmx.'.tm-exchange.com/get.aspx?action=trackscreen&id='. $this->data[0].'&.jpg', true);

	$this->Username->setPosition(15, 2);
	$this->Username->setSizeX(60);
	$this->Username->setSizeY(5);
	$this->Username->setTextSize(3);
	$this->panel->addComponent($this->Username);
	$this->TmxID->setPosition(1, 8);
	$this->TmxID->setSizeX(30);
	$this->TmxID->setSizeY(4);
	$this->TmxID->setTextSize(2);
	$this->panel->addComponent($this->TmxID);
	$this->Uploaded->setPosition(1, 12);
	$this->Uploaded->setSizeX(30);
	$this->Uploaded->setSizeY(4);
	$this->Uploaded->setTextSize(2);
	$this->panel->addComponent($this->Uploaded);
	$this->Environment->setPosition(1, 16);
	$this->Environment->setSizeX(30);
	$this->Environment->setSizeY(4);
	$this->Environment->setTextSize(2);
	$this->panel->addComponent($this->Environment);
	$this->Gameversion->setPosition(1, 20);
	$this->Gameversion->setSizeX(30);
	$this->Gameversion->setSizeY(4);
	$this->Gameversion->setTextSize(2);
	$this->panel->addComponent($this->Gameversion);
	$this->Length->setPosition(1, 24);
	$this->Length->setSizeX(30);
	$this->Length->setSizeY(4);
	$this->Length->setTextSize(2);
	$this->panel->addComponent($this->Length);
	$this->Style->setPosition(1, 28);
	$this->Style->setSizeX(30);
	$this->Style->setSizeY(4);
	$this->Style->setTextSize(2);
	$this->panel->addComponent($this->Style);
	$this->Mood->setPosition(1, 32);
	$this->Mood->setSizeX(30);
	$this->Mood->setSizeY(4);
	$this->Mood->setTextSize(2);
	$this->panel->addComponent($this->Mood);
	$this->Difficulty->setPosition(1, 36);
	$this->Difficulty->setSizeX(30);
	$this->Difficulty->setSizeY(4);
	$this->Difficulty->setTextSize(2);
	$this->panel->addComponent($this->Difficulty);
	$this->Routes->setPosition(1, 40);
	$this->Routes->setSizeX(30);
	$this->Routes->setSizeY(4);
	$this->Routes->setTextSize(2);
	$this->panel->addComponent($this->Routes);
	$this->Image->setPosition(37, 10);
	$this->Image->setSizeX(35);
	$this->Image->setSizeY(30);
	$this->panel->addComponent($this->Image);
	$this->btnTrack->setPosition(14, 46);
	$this->btnTrack->setStyle(Button::CardButtonSmallWide);
	$this->panel->addComponent($this->btnTrack);
    }  
    
    function setData($data)
    {
        $this->data = $data;
    }
	
	function setTargetTmx($tmx) {
		$this->tmx = $tmx;
	}
	
    function destroy()
    {
        parent::destroy();
    }
}
?>
